package com.atguigu.lease.model.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

public enum AppointmentStatus implements BaseEnum {


    WAITING(1, "待看房"),

    CANCELED(2, "已取消"),

    VIEWED(3, "已看房");


    // springmvc到数据库时在MybatisPlus中将`AppointmentStatus`对象到`code`属性之间的互相映射
    @EnumValue  //告诉框架在持久化到数据库时使用哪个字段作为枚举的值
    // springmvc到前端时在HTTPMessageConverter中将`AppointmentStatus`对象到`code`属性之间的相互映射
    @JsonValue  //指示在进行JSON序列化时应使用哪个字段
    private Integer code;


    private String name;

    AppointmentStatus(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public Integer getCode() {
        return this.code;
    }

    @Override
    public String getName() {
        return this.name;
    }
}
